package minimumAbsDifference;

import java.util.*;

public class Solution {
    public List<List<Integer>> minimumAbsDifference(int[] arr) {
        //
        Arrays.sort(arr);
        List<List<Integer>>ans = new ArrayList<>();
        // 找到最小的绝对值差
        int minSub = 0;
        for (int i = 1; i < arr.length; i++) {
            minSub = Math.min(arr[i]-arr[i-1],minSub);
        }
        // 找到等于minSub的元素
        for (int i = 1; i < arr.length; i++) {
            if(arr[i]-arr[i-1] == minSub){
                List<Integer> list = new ArrayList<>();
                list.add(arr[i]);
                list.add(arr[i-1]);
                ans.add(list);
            }
        }
        return ans;
    }
}
